<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <base th:href="@{/}">
    <title>尚硅谷会员注册页面</title>
    <link type="text/css" rel="stylesheet" href="static/css/style.css">
    <style type="text/css">
        h1 {
            text-align: center;
            margin-top: 200px;
        }

        h1 a {
            color: red;
        }
    </style>
</head>
<body>
<div id="app">
<div id="header">
    <a href="index.html">
        <img class="logo_img" alt="" src="static/img/logo.gif"/>
    </a>
    <div>
        <span>欢迎 <span class="um_span" th:text="${session.existUser.userName}">张总</span>光临尚硅谷书城</span>
        <a href="../order/order.html">我的订单</a>
        <a  @click.prevent="logout">注销</a>&nbsp;&nbsp;
        <a href="index.html">返回</a>
    </div>
</div>

<div id="main">

    <h1>欢迎回来 <a href="index.html">转到主页</a></h1>

</div>

<div id="bottom">
			<span>
				尚硅谷书城.Copyright &copy;2015
			</span>
</div>
</div>
</body>
<script src="static/script/axios.js"></script>
<script src="static/script/vue.js"></script>
<script>
    var vue = new Vue({
        el:"#app",
        data:{

        },
        methods:{
            logout() {
                var existUser = sessionStorage.getItem("existUser");
                if(existUser != null){
                    //在登录状态
                    axios({
                        method:"get",
                        url:"/bookstore/user",
                        params:{
                            method:"logout"
                        }
                    }).then(function (res) {
                        var data = res.data;
                        if(data.flag){
                            sessionStorage.removeItem("existUser");
                            location.href="/bookstore/index.html";
                        }else {
                            alert("注销失败!");
                        }
                    })
                }else {
                    //不在登录状态
                    alert("你还没有登录!");
                    location.href="/bookstore/user?method=toLoginPage";
                }
            }
        }
    });
</script>
</html>